/**
 * Copyright (C), 2020-2021 by colley.ma
 * File Name: RateLimitEventInfo.java
 * Encoding: UTF-8
 * Date: 2021年5月8日 上午11:52:17
 * History:
 */
package com.swak.frame.ratelimit.event;

import com.swak.frame.dto.base.DTO;
import com.swak.frame.ratelimit.LimitType;
import com.swak.frame.ratelimit.config.LimitCommand;

public class RateLimitEventInfo implements DTO {

    private static final long serialVersionUID = -2439102025117310839L;

    private String resource;

    private LimitType limitType;

    private String name;

    private double rate;

    private int instances;

    private boolean dynamic;

    public RateLimitEventInfo() {}

    public static RateLimitEventInfo newRateLimitEventInfo(String resource, LimitCommand config,
        LimitType limitType) {
        RateLimitEventInfo eventInfo = new RateLimitEventInfo();
        eventInfo.setResource(resource);
        eventInfo.setDynamic(config.isDynamic());
        eventInfo.setInstances(config.getInstances());
        eventInfo.setName(config.getName());
        eventInfo.setRate(config.getQps());
        eventInfo.setLimitType(limitType);
        return eventInfo;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public int getInstances() {
        return instances;
    }

    public void setInstances(int instances) {
        this.instances = instances;
    }

    public boolean isDynamic() {
        return dynamic;
    }

    public void setDynamic(boolean dynamic) {
        this.dynamic = dynamic;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public LimitType getLimitType() {
        return limitType;
    }

    public void setLimitType(LimitType limitType) {
        this.limitType = limitType;
    }



}
